<script type="text/html" template>
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/moneyManage/addNewPerone.css" />
  <link rel="stylesheet" href="{{ layui.setter.base }}style/alert.css">
</script>
  <style scoped>
    .addPoners {
      text-align: center;
      font-weight: bold;
      font-size: 13px;
      margin-bottom: 5px;
    }
    .False{
      font-size: 20px;
      color: red;
      position: absolute;
      left: 29px;
      top: 4px;
    }
  </style>
</head>

<body>
  <div class="layui-form row" lay-filter="layuiadmin-form-project" id="layuiadmin-form-project">
    <div class="layui-form-item">
      <label class="layui-form-label"><i class="False">*</i>工号：</label>
      <div class="layui-input-block">
        <select name="tcHrGen01" lay-filter="tcHrGen01" lay-search id="selectOne" lay-verify="required">
        </select>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">姓名：</label>
      <div class="layui-input-block">
        <input type="text" name="gen02" placeholder="" autocomplete="off" class="tree layui-input" />
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">部门：</label>
      <div class="layui-input-block">
        <input type="text" name="gem02" placeholder="" autocomplete="off" class="tree layui-input" />
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">岗位：</label>
      <div class="layui-input-block">
        <input type="text" name="tcHrJob" placeholder="" autocomplete="off" class="tree layui-input" />
      </div>
    </div>

    <div class="footer layui-btn-container">
      <div class="layui-form-item">
        <button class="btn1 layui-btn layui-btn-radius layui-btn-primary" lay-filter="layuiadmin-app-form-submit"
          lay-submit>
          确定
        </button>
        <button class="btn2 layui-btn layui-btn-radius layui-btn-primary">
          取消
        </button>
      </div>
    </div>
  </div>
</body>
<script>
  layui.use(
    [
      "admin",
      "form",
      "user",
      "api",
      "table",
      "utill",
      "view",
      "laypage",
      "laytpl",
      "laydate",
      "jquery",
      "layer"
    ],
    function () {
      var table = layui.table,
        setter = layui.setter,
        laytpl = layui.laytpl,
        api = layui.api,
        utill = layui.utill,
        form = layui.form,
        element = layui.element,
        laypage = layui.laypage,
        form = layui.form,
        admin = layui.admin,
        view = layui.view,
        laytpl = layui.laytpl,
        laypage = layui.laypage,
        laydate = layui.laydate,
        layer = layui.layer,
        $ = layui.$;
      // 再一次渲染
      form.render();
      //新增人员(班次管理)
      var gen01 = {};
      admin.req({
        type: "post",
        url: api.host + api.selectAllGen01,
        dataType: "json",
        contentType: "application/json",
        data: JSON.stringify(gen01),
        success: function (response) {
          var list = response.data;
          if (list != null || list.size > 0) {
            var _list = "<option></option>";
            list.forEach(item => {
              _list += `<option value=${item.tcRlgsGen01}>${item.tcRlgsGen01}</option>`;
            });
            $("#selectOne").append(_list);
            form.render("select");
          }
        }
      });

      // 下面带出的数据
      form.on("select(tcHrGen01)", function (data) {
        var selectOne = $("#selectOne").val();
        admin.req({
          url: api.host + api.selectGenDetail,
          type: "get",
          data: { gen01: selectOne },
          success: function (res) {
            var msg = res.data;
            // 回显效果
            form.val("layuiadmin-form-project", {
              gem02: msg.gem02, //姓名
              gen02: msg.gen02, //部门
              tcHrJob: msg.tcHrJob //岗位
            });
          }
        });
      });
    }
  );
</script>

</html>